package plus.feifei.clc;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 2 * @Author: feifei
 * 3 * @Date: 2021/4/21 22:02
 * 4
 */
public class TestMain {
    public static void main(String[] args) throws IOException {
        Files.walk(Paths.get("E:\\ide_java\\forest"))
                .filter(v-> v.toString().endsWith(".java"))
                .forEach(TestMain::remove);
    }
    private static void remove(Path v) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(v.toString())));
            String t="";
            StringBuilder sb=new StringBuilder();
            while((t=br.readLine())!=null){
                if(t.contains("//")||t.contains("*")){
                    continue;
                }
                sb.append(t).append("\n");
            }
            br.close();
            // 将文件写回去
            FileOutputStream fos = new FileOutputStream(v.toString());
            fos.write(sb.toString().getBytes());
            fos.flush();
            fos.close();
            System.out.println(v);
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
